#include <iostream>
#include <vector>

using namespace std;

class Solution
{
public:
    int minimumSubarrayLength(vector<int>& nums, int k)
    {
        int ini_sum = 0;
        for (size_t i = 0; i < nums.size(); i++)
        {
            ini_sum |= nums[i];
        }
        if (ini_sum < k) return -1;
        int cnt = nums.size();
        int temp = 0;
        for (size_t i = 0; i < nums.size(); i++)
        {
            int sum = 0;
            for (size_t j = i; j < nums.size(); j++)
            {
                sum |= nums[j];
                if (sum >= k)
                {
                    temp = j - i + 1;
                    break;
                }
            }
            if (temp < cnt)
            {
                cnt = temp;
            }
        }
        return cnt;
    }
};

int main()
{
    vector<int> nums = { 32, 2, 24, 1 };
    int k = 35;
    Solution solution;
    int result = solution.minimumSubarrayLength(nums, k);
    cout << "Minimum subarray length :" << result << endl;
    return 0;
}
